<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<!--<link rel="stylesheet" type="text/css" href="css/style.css"/>-->
        <style>
*{
	margin: 0;
	padding: 0;
	border: 0;
	list-style: none;
}
body{
	background-color: #262A42;
}
#box{
	width: 100%;
}
.box{
	width: 100%;
}
.header{
	font-size: 14px;
	color: #FFFFFF;
	background-color: #181B2A;
	margin-bottom: 10px;
	padding-top: 20px;
	padding-bottom: 20px;
	overflow: hidden;
}
.header_list{
	float: left;
	width: 16.5%;
	text-align: center;
}
.header_list p{
	padding-top: 5px;
	padding-bottom: 5px;
}
.top_price{
	color: #FB1D1D;
	font-size: 17px;
}
.content{
	overflow: hidden;
}
.content_top{
	overflow: hidden;
}
.content_left{
	float: left;
	width: 49%;
	
	background-color: #181B2A;
}
.content_right{
	float: right;
	width: 49%;
	background-color: #181B2A;
}
@media only screen and (min-width: 350px) and (max-width: 425px) {
	.content_left{
		float: none;
		width: 100%;
		margin-bottom: 20px;
	}
	.content_right{
		float: none;
		width: 100%;
	}
}
.tab{
	height: 50px;
	margin: 0 auto;
	margin-top: 30px;
	margin-bottom: 30px;
	padding: 0 10px;
	overflow: hidden;
}
.tab_list{
	float: left;
	width: 50%;
	line-height: 50px;
	text-align: center;
	color: #FFFFFF;	
	cursor: pointer;
	background-color: #262A42;
}
.active{
	background-color: #181B2A;
	color: skyblue;
}
.tab_cnt{
	width: 375px;
	margin: 0 auto;
	display: none;
	font-size: 12px;
}
.show{
	display: block;
}
.tab_cnt_list{
	/*overflow: hidden;*/
	height: 35px;
	line-height: 35px;
	margin-bottom: 20px;
	color: #FFFFFF;
}
.tab_cnt_list_left{
	float: left;
	width: 100px;
	text-align: right;
}
.tab_cnt_list_right{
	float: left;
	width: 275px;
}
.tab_cnt_list_right span{
	font-size: 16px;
	color: #FB1D1D;
}
.tab_cnt_list_right input{
	width: 298px;
	height: 31px;
	line-height: 31px;
	background-color: transparent;
	border: 1px solid #FFFFFF;
}
.submit{
	text-align: center;
}
.buy,.sell{
	width: 300px;
	height: 40px;
	line-height: 40px;
	text-align: center;
	border-radius: 4px;
    cursor: pointer;
    background: #F9505D;
    color: #FFFFFF;
	margin-top: 20px;
	margin-bottom: 50px;
}
#ewm{
	width: 540px;
	/*height: 466px;*/
	margin-top: -500px;
	margin-left: -233px;
	position:fixed;
	z-index: 10000;
    top: 50%;
    left: 50%;
	background-color: #FFFFFF;
	display: none;
    overflow: hidden;
    text-align: center;
}
.ewm{
	padding-top: 35px;
}
.ewm img{
	width: 350px;
	height: 350px;

}
.ewm_text{
	padding-top: 3px;
	font-size: 20px;
	color: #000000;
}
.shut{
	float: left;
	width: 200px;
	height: 50px;
	line-height: 50px;
	text-align: center;
	font-size: 16px;
	cursor: pointer;
	padding-left: 45px;
}
.credentials{
	float: left;
	height: 50px;
	line-height: 50px;
	font-size: 16px;
	cursor: pointer;
}
#showFileName{
	margin-top: 15px;
}
.mask{
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    background-color: #000000;
    filter: Alpha(Opacity=10);
    -moz-opacity: 0.1;
    opacity: 0.1;
    z-index: 8;
    display: none;
}
.btn{
	overflow: hidden;
	margin-top: 20px;
	margin-bottom: 20px;
}

.content_right>ul{
	height: 40px;
	line-height: 40px;
	overflow: hidden;
	color: #FFFFFF;
	border-bottom: 1px solid red;
}
.content_right ul li{
	float: left;
	width: 25%;
	text-align: center;
}
.mairu{
	height: 240px;
	color: #F9505D;
	font-size: 12px;
	padding-top: 8px;
	border-bottom: 1px dashed #FFFFFF;
	padding-bottom: 6px;
    margin-bottom: 4px;
}
.maichu{
	height: 240px;
	font-size: 12px;
	color: #34C28C;
	padding-bottom: 6px;
    margin-bottom: 4px;
}
.mairu ul,.maichu ul{
	height: 24px;
	line-height: 24px;
}
.entrust{
	margin-top: 20px;
	background-color: #181B2A;
}
.entrust_title{
	height: 36px;
	line-height: 36px;
	font-size: 14px;
    padding-left: 15px;
    text-align: left;
    color: #fff;
}
.entrust_nav ul,.entrust_cnt ul{
	overflow: hidden;
	font-size: 12px;
	border-bottom: 1px solid #646B8C;
}
.entrust_nav ul li{
	color: #FFFFFF;
}
.entrust_nav ul li,.entrust_cnt ul li{
	float: left;
	width: 14.2%;
	height: 44px;
	line-height: 44px;
	text-align: center;
}
.record{
	margin-top: 20px;
	margin-bottom: 50px;
	background-color: #181B2A;
}
.record_nav ul,.record_cnt ul{
	overflow: hidden;
	font-size: 12px;
	border-bottom: 1px solid #646B8C;
}
.record_nav ul li{
	color: #FFFFFF;
}
.record_nav ul li,.record_cnt ul li{
	float: left;
	width: 20%;
	height: 44px;
	line-height: 44px;
	text-align: center;
}
.maichu_color{
	color: #34C28C !important;
}
.mairu_color{
	color: #F9505D !important;
}

        </style>
		<title></title>
	</head>
	<body>
		<div id="box">
			<div class="box">
				<div class="header">
					<div class="header_list">
						<p>最高价</p>
						<span class="top_price" id='max_price'>--</span>
					</div>
					<div class="header_list">
						<p>最低价</p>
						<span class="top_price" style="color: #39E2A2;"  id= 'min_price'>--</span>
					</div>
					<div class="header_list" id = >
						<p>买一价</p>
						<span class="top_price"  id= 'buy_one'>--</span>
					</div>
					<div class="header_list">
						<p>卖一价</p>
						<span class="top_price" id = 'sell_one'>--</span>
					</div>
					<div class="header_list">
						<p>成交量</p>
						<span class="top_price" id='total_num'>--</span>
					</div>
					<div class="header_list">
						<p>日涨跌</p>
						<span class="top_price" id='period'>--</span>
					</div>
				</div>
				<div class="content">
					<div class="content_top">
						<div class="content_left">
							<div class="tab">
								<div class="tab_list active">买入</div>
								<div class="tab_list">卖出</div>
							</div>
							<div class="tab_cnt show">
								<form >
									<div class="tab_cnt_list">
										<div class="tab_cnt_list_left">最佳买价：</div>
										<div class="tab_cnt_list_right"><span id='any_good_buy'>--</span> CNY/VIC</div>
									</div>
									<div class="tab_cnt_list">
										<div class="tab_cnt_list_left">买入价格：</div>
										<div class="tab_cnt_list_right"><input id='buy_price' type="text" /></div>
									</div>
									<div class="tab_cnt_list">
										<div class="tab_cnt_list_left">最大可买：</div>
										<div class="tab_cnt_list_right"><span  id='any_good_buy_num'>--</span> VIC</div>
									</div>
									<div class="tab_cnt_list">
										<div class="tab_cnt_list_left">买入数量：</div>
										<div class="tab_cnt_list_right"><input type="text" id='buy_number' /></div>
									</div>
									<div class="tab_cnt_list">
										<div class="tab_cnt_list_left">总价：</div>
										<div class="tab_cnt_list_right"><span id = 'any_good_buy_price'>--</span> CNY</div>
									</div>
									<div class="submit">
										<input class="buy" type="button" value="买入"/>
									</div>
									<div id="ewm">
										<div class="ewm">
											<img class="ewmimg" id='ewmimg' src="img/ewm.jpg.jpg" />
											<div class="ewm_text" id= 'pay_total_price'>50元</div>
											<div class="btn">
												<div class="shut">撤销</div>
												<div class="credentials" onClick='javascript:$("#chooseImage").click();'>上传凭证</div>
												<input type="file" id="chooseImage" style="display:none" onchange='ophiddenFile();'>
												<input id='showFileName' type='text' readonly />
											</div>
										</div>
									</div>
									<div class="mask"></div>
								</form>
							</div>
							<div class="tab_cnt">
								<form enctype="" method="post">
									<div class="tab_cnt_list">
										<div class="tab_cnt_list_left">最佳卖价：</div>
										<div class="tab_cnt_list_right"><span style="color: #34C28C;" id='any_good_sell'> -- </span> CNY/VIC</div>
									</div>
									<div class="tab_cnt_list">
										<div class="tab_cnt_list_left">卖出价格：</div>
										<div class="tab_cnt_list_right"><input id='sell_price' type="text" /></div>
									</div>
									<div class="tab_cnt_list">
										<div class="tab_cnt_list_left">最大可卖：</div>
										<div class="tab_cnt_list_right"><span style="color: #34C28C;" id='any_good_sell_num'> -- </span> VIC</div>
									</div>
									<div class="tab_cnt_list">
										<div class="tab_cnt_list_left">卖出数量：</div>
										<div class="tab_cnt_list_right"><input id='sell_number' type="text" /></div>
									</div>
									<div class="tab_cnt_list">
										<div class="tab_cnt_list_left">总价：</div>
										<div class="tab_cnt_list_right"><span style="color: #34C28C;" id='any_good_sell_price'> -- </span> CNY</div>
									</div>
									<div class="tab_cnt_list">
										<div class="tab_cnt_list_left">上传二维码：</div>
										<div class="tab_cnt_list_right">
										    <input type="file" id="chooseImage1" name="file">
										       <!-- 保存用户自定义的背景图片 -->
										    <img id="cropedBigImg" value='custom' style="width: 150px; height: 150px;" data-address='' />
										</div>
									</div>
									<div class="submit">
										<input class="sell" value="卖出" onclick='javascript:document.getElementById("chooseImage1").click();' style="background-color: #34C28C;"/>
									</div>
								</form>
							</div>
						</div>
						<div class="content_right">
							<ul>
								<li>买/卖</li>
								<li>价格</li>
								<li>数量</li>
								<li>金额</li>
							</ul>
							<div class="mairu" id = 'sell'>
							</div>
							<div class="maichu" id='buy'>
							</div>
						</div>
					</div>
					<div class="entrust">
						<div class="entrust_title">待确认</div>
						<div class="entrust_nav">
							<ul>
								<li>时间</li>
								<li>买入/卖出</li>
								<li>价格	</li>
								<li>总量</li>
								<li>成交量</li>
								<li>成交金额</li>
								<li>操作</li>
							</ul>
						</div>
						<div class="entrust_cnt" id="queren_cnt">
							<ul class="maichu_color">
								<li>04-30 11:01:15</li>
								<li>卖出</li>
								<li>89.979</li>
								<li>1</li>
								<li>0</li>
								<li>89.97900000</li>
								<li>撤销</li>
							</ul>
						</div>
					</div>
					<div class="entrust">
						<div class="entrust_title">我的委托</div>
						<div class="entrust_nav">
							<ul>
								<li>时间</li>
								<li>买入/卖出</li>
								<li>价格	</li>
								<li>成交量</li>
								<li>成交中</li>
								<li>已成交金额</li>
								<li>操作</li>
							</ul>
						</div>
						<div class="entrust_cnt" id="entrust_cnt">
							<ul class="maichu_color">
								<li>04-30 11:01:15</li>
								<li>卖出</li>
								<li>89.979</li>
								<li>1</li>
								<li>0</li>
								<li>89.97900000</li>
								<li>撤销</li>
							</ul>
						</div>
					</div>
					<div class="record">
						<div class="entrust_title">最新成交记录(全站)</div>
						<div class="record_nav">
							<ul>
								<li>时间</li>
								<li>买入/卖出</li>
								<li>成交价</li>
								<li>成交量</li>
								<li>总额</li>
							</ul>
						</div>
						<div class="record_cnt" id='record_cnt'>
							<ul class="maichu_color">
								<li>11:01:15</li>
								<li>卖出</li>
								<li>89.979</li>
								<li>89.979</li>
								<li>89.97900000</li>
							</ul>
							<ul class="mairu_color">
								<li>11:01:15</li>
								<li>买入</li>
								<li>89.979</li>
								<li>89.979</li>
								<li>89.97900000</li>
							</ul>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script src="jquery.min.js"></script>
		<script type="text/javascript">
			$(function(){
				var form = {};
				form.url = window.location.host;

				form.storage = (function(){
					localStorage.setItem('userid',localStorage.getItem('userid')?localStorage.getItem('userid') : 0);
					localStorage.setItem('type',1);
					localStorage.setItem('good_price',0);
					localStorage.setItem('buy_one',0);
					localStorage.setItem('max_number','');
					localStorage.setItem('buy_number',0);
					localStorage.setItem('buy_price',0);
					localStorage.setItem('total_money',0);
					localStorage.setItem('last_id',0);
					localStorage.setItem('order_id',0);
					localStorage.setItem('max_sell',0);
					localStorage.setItem('sell_price',0);
					localStorage.setItem('sell_number',0);
					localStorage.setItem('sell_total',0);
					localStorage.setItem('request_url',window.location.host);
				})();

				form.getparam=(function(){
					$.post('http://'+form.url+"/model/ctc.php?method=index",{uid:localStorage.getItem('userid')},function(data){
						localStorage.setItem('user',JSON.stringify(data));
					},'json');
				})();
				form.selllist = function(){
					$.post('http://'+form.url+"/model/ctc.php?method=selllist",{},function(data){
						$('#sell').empty();
						if(data){
							if(data.length < 10){
								var l = 10 - data.length;
								for(var i = 1;i <= l;i++){
									var obj = {};
									obj.mum = 0;
									obj.price = 0;
									obj.total = 0;
									data.push(obj);
								}
								data=data.reverse();
								var str = '';
								$(data).each(function(index){
									str += '<ul>';
									str += '<li>卖'+ (10 - index) +'</li>';
									str += '<li>'+ this.price +'</li>';
									str += '<li>'+ this.mum +'</li>';
									str += '<li>'+ this.total+'</li>';
									str += '</ul>';
								});
								$('#sell').html(str);
							}else{
								data=data.reverse();
								var str = '';
								$(data).each(function(index){
									str += '<ul>';
									str += '<li>卖'+ (10 - index) +'</li>';
									str += '<li>'+ this.price +'</li>';
									str += '<li>'+ this.mum +'</li>';
									str += '<li>'+ this.total+'</li>';
									str += '</ul>';
								});
								$('#sell').html(str);
							}
						}else{
							var d = new Array(); 
							for(var i = 1;i <= 10;i++){
								var obj = {};
								obj.mum = 0;
								obj.price = 0;
								obj.total = 0;
								d.push(obj);
							}
							var str = ''; 
							$(d).each(function(index){
								str += '<ul>';
								str += '<li>卖'+ (10 - index) +'</li>';
								str += '<li>'+ this.price +'</li>';
								str += '<li>'+ this.mum +'</li>';
								str += '<li>'+ this.total+'</li>';
								str += '</ul>';
							});
							console.log(str);
							$('#sell').html(str);
						}
					},'json');
				};

				form.queren_cnt = function(){
					$.post('http://'+form.url+"/model/ctc.php?method=queren_cnt",{userid:localStorage.getItem('userid')},function(data){
						var str ='';
						if(data){
							$(data).each(function(){
								str += '<ul class="maichu_color">';
								str += '<li>'+this.datetimes+'</li>';
								str += '<li>'+this.types+'</li>';
								str += '<li>'+this.price+'</li>';
								str += '<li>'+this.num+'</li>';
								str += '<li>'+this.dum+'</li>';
								str += '<li>'+this.total+'</li>';
								str += '<li><button onclick="queren_order('+this.id+')">已到帐</button></li>';
								str += '</ul>';
							});
						}
						$('#queren_cnt').empty();
						$('#queren_cnt').html(str);
					},'json');
				}

				form.buylist = function(){
					$.post('http://'+form.url+"/model/ctc.php?method=buylist",{},function(data){
						$('#buy').empty();
						data=data.reverse();
						if(data.length < 10){
							var l = 10 - data.length;
							for(var i = 1;i <= l;i++){
								var obj = {};
								obj.mum = 0;
								obj.price = 0;
								obj.total = 0;
								data.unshift(obj);
							}
							data=data.reverse();
							
							var str = '';

							$(data).each(function(index){
								str += '<ul>';
								str += '<li>买'+ (index + 1) +'</li>';
								str += '<li>'+ this.price +'</li>';
								str += '<li>'+ this.mum +'</li>';
								str += '<li>'+ this.total+'</li>';
								str += '</ul>';
							});
							$('#buy').html(str);
						}else{
							data=data.reverse();
							var str = '';
							$(data).each(function(index){
								str += '<ul>';
								str += '<li>买'+ (index + 1) +'</li>';
								str += '<li>'+ this.price +'</li>';
								str += '<li>'+ this.mum +'</li>';
								str += '<li>'+ this.total+'</li>';
								str += '</ul>';
							});
							$('#buy').html(str);
						}
					},'json');
				};

				form.min_price = function(){
					$.post('http://'+form.url+"/model/ctc.php?method=min_price",{},function(data){
						if(data && data.price > 0){
							$('#min_price').empty();
							$('#min_price').html(data.price);
						}
					},'json');
				};

				form.get_user_vic = function(){
					$.post('http://'+form.url+"/model/ctc.php?method=get_user_vic",{userid:localStorage.getItem('userid')},function(data){
						$('#any_good_sell_num').html(data.num);
						localStorage.setItem('max_sell',data.num);
					},'json');
				};


				form.max_price = function(){
					$.post('http://'+form.url+"/model/ctc.php?method=max_price",{},function(data){
						if(data && data.price > 0){
							$('#max_price').empty();
							$('#max_price').html(data.price);
						}
					},'json');
				};

				form.buy_one = function(){
					$.post('http://'+form.url+"/model/ctc.php?method=buy_one",{},function(data){
						if(data && data.price > 0){
							$('#buy_one').empty();
							$('#buy_one').html(data.price);
							$('#any_good_sell').empty();
							$('#any_good_sell').html(data.price);
						}
					},'json');
				};

				form.sell_one = function(){
					$.post('http://'+form.url+"/model/ctc.php?method=sell_one",{},function(data){
						if(data && data.price > 0){
							$('#sell_one').empty();
							$('#sell_one').html(data.price);
							$('#any_good_buy').empty();
							$('#any_good_buy').html(data.price);
							localStorage.setItem('good_price',data.price);
						}
					},'json');
				};

				form.total_num = function(){
					$.post('http://'+form.url+"/model/ctc.php?method=total_num",{},function(data){
						if(data && data.total > 0){
							$('#total_num').empty();
							$('#total_num').html(data.total);
						}
					},'json');
				};

				form.period = function(){
					$.post('http://'+form.url+"/model/ctc.php?method=period",{},function(data){
						$('#period').empty();
						$('#period').html(data.period);
					},'json');
				};

				form.entrust_cnt = function(){
					$.post('http://'+form.url+"/model/ctc.php?method=entrust_cnt",{userid:localStorage.getItem('userid')},function(data){
						//console.log(data);
						$('#entrust_cnt').empty();
						var str = '';
						if(data){
							$(data).each(function(){
								if(this.type==1){
									str += '<ul class="maichu_color">';
								}else{
									str += '<ul class="mairu_color">';
								}
								str += '<li>'+this.addtime+'</li>';
								str += '<li>'+this.types+'</li>';
								str += '<li>'+this.price+'</li>';
								str += '<li>'+this.remain+'</li>';
								str += '<li>'+this.dum+'</li>';
								str += '<li>'+this.money+'</li>';
								if(this.status == 0){
									str += '<li><button onclick="my_cexiao('+this.id+')">'+this.status_name+'</button></li>';
								}else{
									str += '<li>'+this.status_name+'</li>';
								}
								str += '</ul>';
							});
						}
						$('#entrust_cnt').html(str);
					},'json');
				};

				form.record_cnt = function(){
					$.post('http://'+form.url+"/model/ctc.php?method=record_cnt",{},function(data){
						console.log(data);
						var str ='';
						if(data){
							$(data).each(function(){
								if(this.type==1){
									str += '<ul class="mairu_color">';
								}else{
									str += '<ul class="maichu_color">';
								}
								str += '<li>'+this.datetimes+'</li>';
								str += '<li>'+this.types+'</li>';
								str += '<li>'+this.price+'</li>';
								str += '<li>'+this.num+'</li>';
								str += '<li>'+this.total+'</li>';
								str += '</ul>';
							});
						}
						$('#record_cnt').html(str);
					},'json');
				}

				form.getfocus = (function(){
					//focus
					document.getElementById('buy_price').focus();
				})();

				form.buy_price = (function(){
					$('#buy_price').on('change',function(){
						if(localStorage.getItem('type') == 1){
							var price =  parseFloat(this.value);
							//非NaN
							if(isNaN(price)){
								this.value = '';
								this.focus();
								alert('请输入数字');
								return true;
							}
							if(price.toFixed(1) <= 0){
								this.value = '';
								this.focus();
								alert('输入值应大于0，并保留一位小数');
								return true;
							}
							this.value = price.toFixed(1);
							var type = localStorage.getItem('type');
							$.post('http://'+form.url+"/model/ctc.php?method=buy_order",{price:this.value,type:type},function(data){
								if(data.code!=200){
									document.getElementById('buy_price').focus();
									alert(data.msg);
								}else{
									$('#buy_price').val(data.data.price);
									$('#any_good_buy_num').html(data.data.number);
									$('#buy_number').empty();
									$('#buy_number').focus();
									if(data.data.img){
										document.getElementById('ewmimg').src = data.data.img;
									}
									localStorage.setItem('buy_price',data.data.price);
									localStorage.setItem('max_number',data.data.number);
								}
							},'json');
						}else{
							alert('数据错误，请更换浏览器');
						}
					});
					//数量
					$('#buy_number').on('change',function(){
						var buy_num = parseFloat(this.value);
						//非NaN
						if(isNaN(buy_num)){
							this.value = '';
							this.focus();
							alert('请输入数字');
							return true;
						}
						if(buy_num.toFixed(1) <= 0){
							this.value = '';
							this.focus();
							alert('输入值应大于0，并保留一位小数');
							return true;
						}
						var max_num = localStorage.getItem('max_number');
						if(!max_num){
							document.getElementById('buy_price').focus();
							//return true;
						}
						if(isNaN(parseFloat(max_num))){
							this.value = buy_num.toFixed(1);
							localStorage.setItem('buy_number',this.value);
							$('#any_good_buy_price').html((this.value*10)*($('#buy_price').val()*10)/100);
							localStorage.setItem('total_money',(this.value*10)*($('#buy_price').val()*10)/100);
							//return true;
						}
						if(parseFloat(max_num).toFixed(1) >= buy_num.toFixed(1)){
							this.value = buy_num.toFixed(1);
							localStorage.setItem('buy_number',this.value);
							$('#any_good_buy_price').html((this.value*10)*($('#buy_price').val()*10)/100);
							localStorage.setItem('total_money',(this.value*10)*($('#buy_price').val()*10)/100);
							//return true;
						}else{
							this.value = parseFloat(max_num).toFixed(1);
							localStorage.setItem('buy_number',this.value);
							$('#any_good_buy_price').html((this.value*10)*($('#buy_price').val()*10)/100);
							localStorage.setItem('total_money',(this.value*10)*($('#buy_price').val()*10)/100);
							//return true;
						}
					});

				})();

				form.sell_price= (function(){
					$('#sell_price').on('change',function(){
						var sell_num = parseFloat(this.value);
						//非NaN
						if(isNaN(sell_num)){
							this.value = '';
							this.focus();
							alert('请输入数字');
							return true;
						}
						if(sell_num.toFixed(1) <= 0){
							this.value = '';
							this.focus();
							alert('输入值应大于0，并保留一位小数');
							return true;
						}
						this.value = sell_num.toFixed(1);
						localStorage.setItem('sell_price',this.value);
						document.getElementById('sell_number').focus();
						$('#sell_number').on('change',function(){
							var sell_number = parseFloat(this.value);
							//非NaN
							if(isNaN(sell_number)){
								this.value = '';
								this.focus();
								alert('请输入数字');
								return true;
							}
							if(sell_number.toFixed(1) <= 0){
								this.value = '';
								this.focus();
								alert('输入值应大于0，并保留一位小数');
								return true;
							}
							if(sell_number.toFixed(1) > parseFloat(localStorage.getItem('max_sell'))){
								this.value = '';
								this.focus();
								alert('输入值不能大于最大可卖值');
								return true;
							}
							this.value = sell_number.toFixed(1);
							localStorage.setItem('sell_number',sell_number.toFixed(1));
							$('#any_good_sell_price').html(localStorage.getItem('sell_number') *10 *localStorage.getItem('sell_price')*10/100);
						});
					});
				})();

				form.init = (function(){
					form.selllist();
					form.buylist();
					form.min_price();
					form.max_price();
					form.buy_one();
					form.sell_one();
					form.total_num();
					form.period();
					form.entrust_cnt();
					form.record_cnt();
					form.queren_cnt();
					form.get_user_vic();
					setInterval(function(){
						form.selllist();
						form.buylist();
						form.min_price();
						form.max_price();
						form.buy_one();
						form.sell_one();
						form.total_num();
						form.period();
						form.entrust_cnt();
						form.record_cnt();
						form.queren_cnt();
						form.get_user_vic();
					},3000);
				})();

			});

			$(".buy").click(function(){
				if(localStorage.getItem('userid') <=0 || localStorage.getItem('type') != 1 || localStorage.getItem('good_price') <= 0 || !localStorage.getItem('max_number') || localStorage.getItem('buy_number') <= 0 || localStorage.getItem('buy_price') <= 0 || localStorage.getItem('total_money') <= 0 ){
					alert('缺少必要参数');
				}else if(localStorage.getItem('buy_number')*10*localStorage.getItem('buy_price')*10/100 != localStorage.getItem('total_money')){
					alert('价格错误');
				}else if(parseFloat(localStorage.getItem('good_price')) < parseFloat(localStorage.getItem('buy_price'))){
					alert('价格错误，请重新下单');
				}else if(!isNaN(parseInt(localStorage.getItem('max_number'))) && localStorage.getItem('max_number') <  localStorage.getItem('buy_number')){
					alert('买入数量错误');
				}else{
					if(parseFloat(localStorage.getItem('good_price')) == parseFloat(localStorage.getItem('buy_price'))){
						//下单并付款
						$('#pay_total_price').html(localStorage.getItem('total_money')+'元');
						$.post('http://'+localStorage.getItem('request_url')+"/model/ctc.php?method=push_order",{userid:localStorage.getItem('userid'),type:localStorage.getItem('type'),buy_price:localStorage.getItem('buy_price'),buy_number:localStorage.getItem('buy_number'),img:'img'},function(data){
							//返回订单号
							localStorage.setItem('last_id',data.data.id);
							localStorage.setItem('order_id',data.data.ids);
						},'json');
						//上传凭证
						$("#ewm").css("display","block");
						$(".mask").css("display","block");
					}else{
						//挂单
						$('#pay_total_price').html(localStorage.getItem('total_money')+'元');
						$.post('http://'+localStorage.getItem('request_url')+"/model/ctc.php?method=push_order",{userid:localStorage.getItem('userid'),type:localStorage.getItem('type'),buy_price:localStorage.getItem('buy_price'),buy_number:localStorage.getItem('buy_number')},function(data){
							localStorage.setItem('last_id',data.data.id);
							localStorage.setItem('order_id',data.data.ids);
						},'json');
						location.reload();
						//$("#ewm").css("display","block");
						//$(".mask").css("display","block");
					}
				}
			})
			$(".shut").click(function(){
				$.post('http://'+localStorage.getItem('request_url')+"/model/ctc.php?method=out_order",{id:localStorage.getItem('last_id'),ids:localStorage.getItem('order_id')},function(data){
						console.log(data);			
					},'json');
					$("#ewm").css("display","none");
					$(".mask").css("display","none");
			})

			function queren_order(id){
				$.post('http://'+localStorage.getItem('request_url')+"/model/ctc.php?method=queren_order",{id:id},function(data){
						alert(data.msg);
						location.reload();		
				},'json');
			}

			function my_cexiao(id){
				$.post('http://'+localStorage.getItem('request_url')+"/model/ctc.php?method=my_cexiao",{id:id},function(data){
						alert(data.msg);
						location.reload();		
				},'json');
			}
			

			function ophiddenFile(){
			    var dd = $("#chooseImage").val().split("\\");
			    $("#showFileName").val(dd[dd.length-1]);

	    		//创建FormData对象
		        var data = new FormData();
		        //为FormData对象添加数据
		        $.each($('#chooseImage')[0].files, function(i, file) {
		            data.append('upload_file'+i, file);
		        });

		        //发送数据
		        $.ajax({
		            url:'http://'+localStorage.getItem('request_url')+"/model/ctc.php?method=upload_image", /*去过那个php文件*/
		            type:'POST',  /*提交方式*/
		            data:data,
		            dataType:'json',
		            cache: false,
		            async:true,
		            contentType: false,        /*不可缺*/
		            processData: false,         /*不可缺*/
		            success:function(da){
		            	console.log(da);    
	                	if(da.data.path){
							document.getElementById('ewmimg').src = da.data.path;
							location.reload();
						}
		            },
		            error:function(){
		                alert('上传出错');
		            }
		        });
			}

			var tab_list = document.getElementsByClassName("tab_list");
			var tab_cnt = document.getElementsByClassName("tab_cnt");

			for(var i=0;i<tab_list.length;i++){
			 	tab_list[i].onclick=function(){changes(this);}
			}

			function changes(obj){
				for(var i=0;i<tab_list.length;i++){
				 	if(tab_list[i]==obj){
				 		//tab_list 买
				 		tab_list[i].classList.add("active");
				 		tab_cnt[i].classList.add("show");
						document.getElementById('sell_price').focus();
						localStorage.setItem('type',2);
					}else{
				 		tab_list[i].classList.remove("active");
				 		tab_cnt[i].classList.remove("show");
				 		document.getElementById('buy_price').focus();
				 		localStorage.setItem('type',1);
				 	}
				}
			}

			 $('#chooseImage1').on('change',function(){
		        var filePath = $(this).val(),         //获取到input的value，里面是文件的路径
		            fileFormat = filePath.substring(filePath.lastIndexOf(".")).toLowerCase(),
		            src = window.URL.createObjectURL(this.files[0]); //转成可以在本地预览的格式

		        // 检查是否是图片
		        if( !fileFormat.match(/.png|.jpg|.jpeg/) ) {
		            error_prompt_alert('上传错误,文件格式必须为：png/jpg/jpeg');
		            return;
		        }

		        $('#cropedBigImg').attr('src',src);
		        if(parseFloat(localStorage.getItem('sell_number')).toFixed(1) <= 0 || parseFloat(localStorage.getItem('sell_price')).toFixed(1)<=0){
		        	alert('参数错误');
		        	return false;
		        }
		        //创建FormData对象
		        url = 'http://'+localStorage.getItem('request_url')+"/model/ctc.php?method=upload_image1";
		        url += '&sell_number='+localStorage.getItem('sell_number');
		        url += '&sell_price='+localStorage.getItem('sell_price');
		        url += '&userid='+localStorage.getItem('userid');
		        url += '&type='+2;
		        var data = new FormData();
		        //为FormData对象添加数据
		        $.each($('#chooseImage1')[0].files, function(i, file) {
		            data.append('upload_file'+i, file);
		        });

		        //发送数据
		        $.ajax({
		            url:url, /*去过那个php文件*/
		            type:'POST',  /*提交方式*/
		            data:data,
		            dataType:'json',
		            cache: false,
		            async:true,
		            contentType: false,        /*不可缺*/
		            processData: false,         /*不可缺*/
		            success:function(da){ 
		            	if(da.code != 200){
		            		alert(da.msg);
		            	}else{
		            		alert(da.msg);
		            	}
		            	location.reload();
		            },
		            error:function(){
		                alert('上传出错');
		            }
		        });
			});
		</script>
	</body>
</html>
